var e = require;
var t = module;
var o = exports;
var n;
Object.defineProperty(o, "__esModule", {value: !0}), (o.TreasureChestBox = o.TreasureBox = void 0);
var r,
    s = e("SDK"),
    c = e("AdUtils"),
    l = e("TreasureChest"),
    d = e("UIGetCoinBox"),
    u = cc._decorator,
    p = u.ccclass;
u.property,
    (function (e) {
        (e[(e.COIN = 1)] = "COIN"), (e[(e.DIAMONDS = 2)] = "DIAMONDS"), (e[(e.RADOM = 3)] = "RADOM");
    })((r = o.TreasureBox || (o.TreasureBox = {})));
var h = (function (e) {
    function t() {
        var t = (null !== e && e.apply(this, arguments)) || this;
        return (
            (t.boxData = {
                type: r.DIAMONDS,
                coin: {res: "sdk/TreasureChest/ui/Coin.png", min: 50, max: 200},
                diamonds: {res: "sdk/TreasureChest/ui/icon_cs.png", min: 5, max: 10}
            }),
            (t.boxbannerData = {
                type: r.COIN,
                coin: {res: "sdk/TreasureChest/ui/Coin.png", min: 100, max: 500},
                diamonds: {res: "sdk/TreasureChest/ui/icon_cs.png", min: 5, max: 10}
            }),
            t
        );
    }
    var o;
    return (
        __extends(t, e),
        (o = t),
        Object.defineProperty(t, "Instance", {
            get: function () {
                return null == o._instance && (o._instance = new o()), o._instance;
            },
            enumerable: !1,
            configurable: !0
        }),
        (t.prototype.start = function () {}),
        (t.prototype.cratorTreasureChest = function (e, t, o, n) {
            void 0 === o && (o = null);
            var i = this.boxbannerData;
            e == l.TreasureChestType.NINE && (i = this.boxData),
                cc.resources.load("sdk/config/gameConfig", cc.JsonAsset, function (a, r) {
                    if (a) console.error("Failed to load JSON:", a);
                    else {
                        var d = r.json,
                            u = d[n - 1].boxData;
                        i = u;
                        var p = cc.director.getScene().getChildByName("Canvas"),
                            h = "sdk/TreasureChest/Prefabs/TreasureChest";
                        s.default.Instance.isPortrait() || (h = "sdk/TreasureChest/Prefabs/TreasureChest001"),
                            c.default.instance.loadPrefabs(h, function (a) {
                                console.log(" Trea loadPrefabs");
                                var r = cc.instantiate(a),
                                    s = r.addComponent(l.TreasureChest);
                                (r.group = d[n - 1].boxGroup), p.addChild(r, 999, "Treasure"), s.showView(e, t, o, i);
                            });
                    }
                });
        }),
        (t.prototype.cratorUIGetCoinBox = function (e, t, o, n, i) {
            void 0 === o && (o = null);
            var a = this.boxbannerData;
            e == l.TreasureChestType.NINE && (a = this.boxData);
            var r = this;
            cc.resources.load("sdk/config/gameConfig", cc.JsonAsset, function (s, c) {
                if (s) return console.error("Failed to load JSON:", s), void r.show(l, n, e, t, o, a, i);
                var l = c.json,
                    d = l[n - 1].boxData;
                (a = d), r.show(l, n, e, t, o, a, i);
            });
        }),
        (t.prototype.show = function (e, t, o, n, i, a, r) {
            var l = cc.director.getScene().getChildByName("Canvas"),
                u = "sdk/TreasureChest/Prefabs/UIGetCoinBox";
            s.default.Instance.isPortrait() || (u = "sdk/TreasureChest/Prefabs/UIGetCoinBox001"),
                r == d.CoinBoxType.BIG
                    ? (u = "sdk/TreasureChest/Prefabs/UIGetCoinBigBox2")
                    : r == d.CoinBoxType.TWINS && (u = "sdk/TreasureChest/Prefabs/UIGetCoinBigBox"),
                c.default.instance.loadPrefabs(u, function (s) {
                    console.log(" Trea loadPrefabs");
                    var c = cc.instantiate(s),
                        u = c.getComponent(d.default);
                    (c.group = e[t - 1].boxGroup),
                        console.log("adNode.group:", c.group, t),
                        l.addChild(c, 999, "UIGetCoinBox"),
                        u.showView(o, n, i, a, r);
                });
        }),
        (t.showBoxCount = 1),
        (t._instance = null),
        (o = __decorate([p("TreasureChestBox")], t))
    );
})(cc.Component);
o.TreasureChestBox = h;
